package com.gzu.live.service.impl;

import com.gzu.live.mapper.LiveUserMapper;
import com.gzu.live.pojo.Live;
import com.gzu.live.pojo.LiveUser;
import com.gzu.live.service.LiveUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LiveUserServiceImpl implements LiveUserService {
    @Autowired
    private LiveUserMapper liveUserMapper;

    @Value("hls-server")
    private String hlsServer;

    @Override
    public List<LiveUser> findLiveUserList() {
        return liveUserMapper.findLiveUserList();
    }

    @Override
    public Live findLiveById(int userId) {
        Live live = liveUserMapper.findLiveById(userId);
        live.setStreamUrl(hlsServer + Integer.toString(userId));
        return live;
    }

    @Override
    public List<LiveUser> findLiveUserById(int userId) {
        return liveUserMapper.findLiveUserById(userId);
    }

    @Override
    public int countViewsById() {
        return liveUserMapper.countViewsById();
    }
}
